@extends("admin.index")

@section("title","首页")

@section("css")
    <link rel="stylesheet" href="/static/admin/css/bootstrapValidator.min.css">
@endsection
@section("content")
    <div class="page-inner">
        <div class="page-header">
            <nav class="breadcrumb">
                <div class="left row">
                    <li class="breadcrumb-item"><a href="#">产品管理</a></li>
                    <li class="breadcrumb-item active" aria-current="page">产品分类创建</li>
                </div>
                <div class="right row">
                    <li class="breadcrumb-item"><i class="fa fa-reply"></i></li>
                    <li class="breadcrumb-item active" aria-current="page"><i class="fa fa-refresh"></i> </li>
                </div>
            </nav>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <div class="card-title">
                            <a href="{{route("admin.menu.index")}}" class="btn btn-primary btn-sm btn-border">菜单列表</a>
                        </div>
                    </div>
                    <form action="{{route("admin.menu.store")}}" method="post" id="defaultForm">

                        @include("admin.common.result")
                        @include("admin.common.validate")

                        @csrf
                        <div class="card-body">
                            <div class="form-group">
                                <label for="name">菜单名称</label>
                                <input type="text" class="form-control" id="name" name="name" placeholder="输入菜单名称">
                                {{--                        <small id="emailHelp2" class="form-text text-muted">We'll never share your email with anyone else.</small>--}}
                            </div>
                            <div class="form-group">
                                <label for="pid">选择级别</label>
                                <select class="form-control" id="pid" name="pid">
                                    <option value="0">顶级菜单</option>
                                    @foreach($menu as $val)
                                        <option value="{{$val->id}}">{{$val->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="action">输入链接</label>
                                <input type="text" class="form-control" id="action" name="action" placeholder="请输入链接">
                            </div>
                            <div class="form-group">
                                <label for="icon">输入图标</label>
                                <input type="text" class="form-control" id="icon" name="icon" placeholder="请输入图标">
                            </div>
                            <div class="form-group">
                                <label for="sort">排序值</label>
                                <input type="text" class="form-control" id="sort" name="sort" value="10">
                            </div>
                            {{--                    <div class="form-check">--}}
                            {{--                        <label>Gender</label><br>--}}
                            {{--                        <div class="form-radio">--}}
                            {{--                            <input type="radio" name="like" id="likeL" checked>--}}
                            {{--                            <label for="likeL">李易峰</label>--}}
                            {{--                        </div>--}}
                            {{--                        <div class="form-radio">--}}
                            {{--                            <input type="radio" name="like" id="likeD">--}}
                            {{--                            <label for="likeD">邓伦</label>--}}
                            {{--                        </div>--}}
                            {{--                        <div class="form-radio">--}}
                            {{--                            <input type="radio" name="like" id="likeH">--}}
                            {{--                            <label for="likeH">黄轩</label>--}}
                            {{--                        </div>--}}
                            {{--                        <div class="form-radio">--}}
                            {{--                            <input type="radio" name="like" id="likeZ">--}}
                            {{--                            <label for="likeZ">郑爽</label>--}}
                            {{--                        </div>--}}
                            {{--                    </div>--}}
                        </div>

                        <div class="card-action">
                            <button class="btn btn-success" type="submit">Submit</button>
                            <button class="btn btn-danger">Cancel</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

@section("script")
<script src="/static/admin/js/bootstrapValidator.min.js"></script>
<script>
    $('#defaultForm').bootstrapValidator({
//        live: 'disabled',
        message: '输入的内容无效',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    notEmpty: {
                        message: '菜单名称不可为空'
                    },
                    //长度规则
                    stringLength: {
                        min: 2, //最小值
                        max: 10,//最大值
                        message: '名称的长度在2~10位'
                    },
                }
            },
            pid: {
                validators: {
                    notEmpty: {
                        message: 'pid为必选项'
                    }
                }
            },
            action: {
                validators: {
                    // notEmpty: {
                    //     message: '菜单链接为必填项'
                    // },
                    //正则
                    regexp: {
                        regexp: /^[a-zA-Z_.]+$/,
                        message: '菜单链接只能由字母和下划线组成'
                    }
                }
            },
            icon: {
                validators: {
                    //长度规则
                    stringLength: {
                        max: 30,//最大值
                        message: '菜单图标的最大长度为30位'
                    },
                }
            },
            sort: {
                validators: {
                    notEmpty: {
                        message: '排序值为必填项'
                    },
                    digits :{
                        message: '排序值为数值'
                    }
                }
            },
        }
    });
</script>
@endsection
